﻿#region Using
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.ComponentModel;
using AifMessageHeaderEditor.Lib.Data; 
#endregion

namespace AifMessageHeaderEditor.Lib.Data.MessageDocument.Message.Body
{
    public class MessageBodyData : MessageDataBase, INotifyPropertyChanged
    {
        #region members and consts

        public event PropertyChangedEventHandler PropertyChanged;

        /// <summary>
        /// The Body of the Aif-message
        /// </summary>
        public string Body
        {
            get
            {
                return _xmlNode.InnerXml;
            }
            set
            {
                if (value != this.Body)
                {
                    _xmlNode.InnerXml = value;
                    NotifyPropertyChanged(AppCommon.AIF_BODY);
                }
            }
        }

        #endregion

        #region constructor

        public MessageBodyData(XmlNode bodyNode) : base(bodyNode)
        {}

        #endregion

        #region methods : Notification

        public override void NotifyChanges()
        {
            NotifyPropertyChanged(AppCommon.AIF_BODY);
        }

        /// <summary>
        /// used for the databinding: notifies the controles that are binded 
        /// to the object or properties.
        /// </summary>
        private void NotifyPropertyChanged(String info)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(info));
            }
        }

        #endregion
    }
}